 package srdb.migration.schema.metadata;
 
 
 import java.util.HashMap;
import java.util.Map;

import srdb.migration.MTKException;
import srdb.migration.Utility;
 
 public class Schema extends DBObject
 {
   private String schemaName = null;
   private TableList tables = null;
   private ProcedureList procs = null;
   private ViewList views = null;
   private TriggerList triggers = null;
   private FunctionList functions = null;
   private SequenceList sequences = null;
   private PackageList packages = null;
   private ConstraintList constraints = null;
   private IndexList indexes = null;
   private SynonymList synonyms = null;
   private DBLinkList dbLinkList;
   private RoleList roles = null;
   private UserList users = null;
   private GrantList grants = null;
   private ObjectTypeList objectTypes = null;
   private RuleList rules = null;
   private GroupList groups = null;
   private DomainList domains = null;
   private DataTypeList customTypes = null;
 
   private boolean caseSensitive = false;
 
   private Map<String, String> tableColumnsFilterMap = null;
 
   public Schema(String SchemaName, boolean caseSensitive)
   {
     this.schemaName = SchemaName;
     this.caseSensitive = caseSensitive;
   }
 
   public String getName() {
     return this.schemaName;
   }
 
   public TableList getTables() {
     if (this.tables == null) {
       this.tables = new TableList();
     }
 
     return this.tables;
   }
 
   public void addTable(Table table) {
     if (this.tables == null) {
       this.tables = new TableList();
     }
     this.tables.add(table);
   }
 
   public ProcedureList getProcedures() {
     if (this.procs == null)
       this.procs = new ProcedureList();
     return this.procs;
   }
 
   public void addProcedure(Procedure proc) {
     if (this.procs == null) {
       this.procs = new ProcedureList();
     }
     this.procs.add(proc);
   }
 
   public ViewList getViews() {
     if (this.views == null)
       this.views = new ViewList();
     return this.views;
   }
 
   public void addView(View view) {
     if (this.views == null) {
       this.views = new ViewList();
     }
     this.views.add(view);
   }
 
   public void addSynonym(Synonym syn) {
     if (this.synonyms == null)
       this.synonyms = new SynonymList();
     this.synonyms.add(syn);
   }
 
   public TriggerList getTriggers() {
     if (this.triggers == null)
       this.triggers = new TriggerList();
     return this.triggers;
   }
 
   public void addTrigger(Trigger trigger) {
     if (this.triggers == null) {
       this.triggers = new TriggerList();
     }
     this.triggers.add(trigger);
   }
 
   public FunctionList getFunctions() {
     if (this.functions == null)
       this.functions = new FunctionList();
     return this.functions;
   }
 
   public void addFunction(Function function) {
     if (this.functions == null) {
       this.functions = new FunctionList();
     }
     this.functions.add(function);
   }
 
   public SequenceList getSequences() {
     if (this.sequences == null)
       this.sequences = new SequenceList();
     return this.sequences;
   }
 
   public void addSequence(Sequence sequence) {
     if (this.sequences == null) {
       this.sequences = new SequenceList();
     }
     this.sequences.add(sequence);
   }
 
   public PackageList getPackages() {
     if (this.packages == null)
       this.packages = new PackageList();
     return this.packages;
   }
 
   public void addPackage(Package pack) {
     if (this.packages == null) {
       this.packages = new PackageList();
     }
     this.packages.add(pack);
   }
 
   public SynonymList getSynonyms() {
     if (this.synonyms == null)
       this.synonyms = new SynonymList();
     return this.synonyms;
   }
   public ConstraintList getConstraints() {
     if (this.constraints == null)
       this.constraints = new ConstraintList();
     return this.constraints;
   }
 
   public void addConstraint(Constraint constraint) {
     if (this.constraints == null) {
       this.constraints = new ConstraintList();
     }
     this.constraints.add(constraint);
   }
 
   public void clearConstraintsList() {
     if (this.constraints != null)
       this.constraints.clear();
   }
 
   public IndexList getIndexes()
   {
     if (this.indexes == null)
       this.indexes = new IndexList();
     return this.indexes;
   }
 
   public void addIndex(Index index) {
     if (this.indexes == null) {
       this.indexes = new IndexList();
     }
     this.indexes.add(index);
   }
 
   public RoleList getRoles() {
     if (this.roles == null)
       this.roles = new RoleList();
     return this.roles;
   }
 
   public void addRole(Role role) {
     if (this.roles == null) {
       this.roles = new RoleList();
     }
     this.roles.add(role);
   }
 
   public GrantList getGrants() {
     if (this.grants == null)
       this.grants = new GrantList();
     return this.grants;
   }
 
   public void addGrant(Grant grant) {
     if (this.grants == null) {
       this.grants = new GrantList();
     }
     this.grants.add(grant);
   }
 
   public UserList getUsers() {
     if (this.users == null)
       this.users = new UserList();
     return this.users;
   }
 
   public void addUser(User user) {
     if (this.users == null) {
       this.users = new UserList();
     }
     this.users.add(user);
   }
 
   public void addDBLink(DBLink link) {
     if (this.dbLinkList == null) {
       this.dbLinkList = new DBLinkList();
     }
     this.dbLinkList.add(link);
   }
 
   public DBLinkList getDBLinks() {
     if (this.dbLinkList == null)
       this.dbLinkList = new DBLinkList();
     return this.dbLinkList;
   }
 
   public void addObjectType(ObjectType objType) {
     if (this.objectTypes == null) {
       this.objectTypes = new ObjectTypeList();
     }
 
     this.objectTypes.add(objType);
   }
 
   public ObjectTypeList getObjectTypes() {
     if (this.objectTypes == null) {
       this.objectTypes = new ObjectTypeList();
     }
 
     return this.objectTypes;
   }
 
   public void clearIndexesList() {
     if (this.indexes != null)
       this.indexes.clear();
   }
 
   public RuleList getRules()
   {
     return this.rules;
   }
 
   public void addRule(Rule rule) {
     if (this.rules == null) {
       this.rules = new RuleList();
     }
     this.rules.add(rule);
   }
 
   public GroupList getGroups() {
     return this.groups;
   }
 
   public void addGroup(Group group) {
     if (this.groups == null) {
       this.groups = new GroupList();
     }
     this.groups.add(group);
   }
 
   public DomainList getDomains() {
     return this.domains;
   }
 
   public void addDomain(Domain domain) {
     if (this.domains == null) {
       this.domains = new DomainList();
     }
     this.domains.add(domain);
   }
 
   public DataTypeList getCustomTypes() {
     return this.customTypes;
   }
 
   public void addCustomType(DataType type) {
     if (this.customTypes == null) {
       this.customTypes = new DataTypeList();
     }
     this.customTypes.add(type);
   }
 
   public String getName(boolean quoted)
   {
     if (this.caseSensitive) {
       return "\"" + this.schemaName + "\"";
     }
 
     return this.schemaName;
   }
 
   public boolean isCaseSensitive() {
     return this.caseSensitive;
   }
 
   public boolean hasTableColumn(String tableName, String colName)
     throws MTKException
   {
     Table table = null;
 
     if (this.tables != null) {
       table = getTable(tableName);
 
       if (table != null) {
         return table.hasColumn(colName);
       }
       throw new MTKException("The table metadeta information is not available.");
     }
 
     throw new MTKException("Tables list is not initialized yet.");
   }
 
   public Table getTable(String tableName)
   {
     Table table = null;
 
     if (this.tables != null) {
       for (int i = 0; i < this.tables.size(); i++) {
         if (Utility.removeEnclosingQuotes(this.tables.get(i).getName()).equals(tableName)) {
           table = this.tables.get(i);
           break;
         }
       }
     }
 
     return table;
   }
 
   public DBObject getParent()
   {
     return null;
   }
 
   public String getSchema()
   {
     return null;
   }
 
   public String getFullName()
   {
     return getName();
   }
 
   public void addTableColumnsFilter(String tableName, String columnsFilterList)
   {
     if (this.tableColumnsFilterMap == null) {
       this.tableColumnsFilterMap = new HashMap();
     }
 
     this.tableColumnsFilterMap.put(tableName, columnsFilterList);
   }
 
   public String getTableColumnsFilter(String tableName)
   {
     if (this.tableColumnsFilterMap == null) {
       return null;
     }
 
     return (String)this.tableColumnsFilterMap.get(tableName);
   }
 }

/* 

 * 
 */